#pragma once

#include<stdio.h>
#include<iostream>
#include<sstream>
#include <string>
#include <vector>
#include <fstream>
#include <exception>
#include <stack>

#include "AST.h"
#include "VarTable.h"
#include "ProcTable.h"
#include "ConstTable.h"
#include "PatternTable.h"
#include "Parent.h"
#include "Follows.h"
#include "Modifies.h"
#include "Uses.h"
#include "Calls.h"
#include "LoopTable.h"
#include "StmtLstTable.h"
#include "PlusTable.h"
#include "MinusTable.h"
#include "TimesTable.h"
#include "Contains.h"

using namespace std;

typedef int INTEGER;
typedef int INDEX;
typedef string STRING;

class Parser {
private:
	AST _ast;
	VarTable _varTable;
	ProcTable _procTable;
	ConstTable _constTable;
	PatternTable _patternTable;
	Parent _parent;
	Follows _follows;
	Modifies _modifies;
	Uses _uses;
	Calls _calls;
	LoopTable _loopTable;
	StmtLstTable _stmtLstTable;
	PlusTable _plusTable;
	MinusTable _minusTable;
	TimesTable _timesTable;
	Contains _contains;
	INTEGER _level;
	INTEGER _progline;
	INTEGER _size;
	//vector<TNode> _nodeList;
	//TNode _nodeList[];
	void Match(STRING s);
	void op_Procedure();
	void op_While();
	void op_If();
	void op_Stmt();
	void op_StmtLst();
	void op_Call();
	void op_Assignment();
	void op_Program();
	void opHandler(vector<string> vString);
	vector<string> toPostFix(vector<string> input);
	void reLevel(TNode* node);
	int getOpIndex(string);
public:
	Parser();
	Parser(STRING fileName);
	AST getAST();
	VarTable getVarTable();
	ProcTable getProcTable();
	ConstTable getConstTable();
	PatternTable getPatternTable();
	Parent getParent();
	Follows getFollows();
	Modifies getModifies();
	Uses getUses();
	Calls getCalls();
	StmtLstTable getStmtLstTable();
	LoopTable getLoops();
	PlusTable getPlus();
	MinusTable getMinus();
	TimesTable getTimes();
	Contains getContains();
	TNode getNode(INTEGER num);
	TNode* getNodeList(); 
	bool isConstant(string str);
};